#include <iostream>
#include <string>

int main() {
    std::string sequence;
    std::cout << "Введите скобочную последовательность: ";
    std::cin >> sequence;

    while (sequence.find("()") != std::string::npos || sequence.find("{}") != std::string::npos || sequence.find("[]") != std::string::npos || sequence.find("<>") != std::string::npos) {
        if (sequence.find("()") != std::string::npos) {
            sequence.replace(sequence.find("()"), 2, "");
        }
        if (sequence.find("{}") != std::string::npos) {
            sequence.replace(sequence.find("{}"), 2, "");
        }
        if (sequence.find("[]") != std::string::npos) {
            sequence.replace(sequence.find("[]"), 2, "");
        }
        if (sequence.find("<>") != std::string::npos) {
            sequence.replace(sequence.find("<>"), 2, "");
        }
    }

    if (sequence == "") {
        std::cout << "True" << std::endl;
    }
    if (sequence != "") {
        std::cout << "False" << std::endl;
    }

    return 0;
}
